cmake_minimum_required(
    VERSION 3.0
)

project(os_1)


include_directories(
    ${PROJECT_SOURCE_DIR}/include
)

include(
    ${PROJECT_SOURCE_DIR}/include/exec_try.h
)


set(
    EXECUTABLE_OUTPUT_PATH
    ${PROJECT_SOURCE_DIR}/bin
)


set(
    LIBRARY_OUTPUT_PATH
    ${PROJECT_SOURCE_DIR}/lib
)


# find_package(
#     Threads
#     REQUIRED    COMPONENTS
# )

add_executable(
    book_origin
    "./src/basic/book_origin.c"
)


add_executable(
    book_no_wait
    "./src/basic/book_no_wait.c"
)

add_executable(
    book_global_static
    "./src/basic/book_global_static.c"
)


add_executable(
    exec_try
    "./src/experiments/exec_try.c"
)

add_executable(
    test_environ
    "./src/experiments/test_environ.c"
)

add_executable(
    exec_in_son
    "./src/full_mark/exec_in_son.c"
)

add_executable(
    hello_world
    "./src/tools/hello_world.c"
)

add_executable(
    system_try
    "./src/experiments/system_try.c"
)


add_executable(
    system_in_son
    "./src/full_mark/system_in_son.c"
)


add_executable(
    shared_variable
    "./src/full_mark/shared_variable.c"
)

target_link_libraries(
    shared_variable
    PUBLIC pthread
)


add_executable(
    get_thread_num
    "./src/experiments/get_thread_num.c"
)

add_executable(
    create_thread
    "./src/experiments/create_thread.c"
)

# 注意，pthread不是ANSI 的C标准库，因此不在gcc的自动搜索路径中
# pthread是被Linux收录第三方库，因此要额外指定链接这个库
target_link_libraries(
    create_thread
    PUBLIC
    pthread
)


add_executable(
    died_thread
    "./src/full_mark/died_thread.c"
)

target_link_libraries(
    died_thread
    PUBLIC pthread
)

add_executable(
    wait_thread_exit
    "./src/full_mark/wait_thread_exit.c"
)

target_link_libraries(
    wait_thread_exit
    PUBLIC pthread
)

add_executable(
    convert_types
    "./src/experiments/convert_types.c"
)

add_executable(
    semaphore_try
    "./src/full_mark/semaphore_try.c"
)

target_link_libraries(
    semaphore_try
    PUBLIC
    pthread
)

add_executable(
    semaphore_try1
    "./src/full_mark/semaphore_try1.c"
)

target_link_libraries(
    semaphore_try1
    PUBLIC pthread
)